from django.db import models
import uuid
from webapp.models import Group

# Create your models here.
class AppCatagory(models.Model):
    id =  models.AutoField(primary_key=True)
    name = models.CharField(max_length=16)

    def __str__(self):
        return self.name

class App(models.Model):
    id =  models.AutoField(primary_key=True)
    name = models.CharField(max_length=16,unique=True)
    describe = models.TextField(max_length=30,null=True,blank=True)
    index = models.CharField(max_length=16,null=True,blank=True)
    appcatagory = models.ForeignKey(AppCatagory,on_delete=models.CASCADE,blank = True,null=True)
    group = models.ManyToManyField(Group,blank = True)
    scripts = models.FileField(upload_to="roles",null=True,blank=True)

    def __str__(self):
        return self.name

class AppConfig(models.Model):
    id = models.AutoField(primary_key=True)
    text = models.TextField(max_length=30, null=True, blank=True)
    uuid = models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False)
    mod_date = models.DateTimeField('最后修改日期', auto_now=True)
    app = models.ForeignKey(App, on_delete=models.CASCADE, blank=True, null=True)
    active = models.BooleanField(blank=True,null=True)

    def __str__(self):
        return self.version






